/**
 * @param {number[]} nums
 * @return {number}
 */
var arrayPairSum = function(nums) {
  nums.sort((a, b) => a - b);
  let count = 0;
  for(let i = 0; i < nums.length; i++) {
    if(i % 2 == 0) count += nums[i];
  }
  return count;
};
let nums = [1,4,3,2];
console.log(arrayPairSum(nums));
nums = [6,2,6,5,1,2];
console.log(arrayPairSum(nums));
